<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	<a4j:loadScript src="/js/jquerymaskedinput-121.js" />
	<a4j:outputPanel id="viaturaChangePanel" ajaxRendered="true">
		<h:form>
			<rich:panel styleClass="rich-stglpanel-body">
				<f:facet name="header">#{messages['label.viaturas']}</f:facet>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.unidade.operacional']}</ui:define>
					<h:selectOneMenu
						value="#{viaturaAction.entity.unidadeOperacional}" 
						label="#{messages['label.unidade.operacional']}" 
						required="false"
						style="width:300px;">
						<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
						<s:selectItems
							value="#{unidadeOperacionalAction.resultList}"
							var="_unidadeOperacional"
							label="#{_unidadeOperacional.descricao}"
							noSelectionLabel="#{messages['label.selecione']}"/>
					</h:selectOneMenu>
					<rich:spacer width="5px"/>
					<s:link
						view="/pages/unidade/index.xhtml" 
						alt="#{messages['label.incluir.unidade.operacional']}"
						title="#{messages['label.incluir.unidade.operacional']}"
						ajaxSingle="true"
						id="grupoEventoModalLink">
						<h:graphicImage 
							url="/img/forward-icon.png"
							style="vertical-align:middle;"/>
						<f:param name="from" value="#{facesContext.viewRoot.viewId}"/>
					</s:link>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.prefixo']}</ui:define>
					<h:inputText 
						id="prefixo"
						value="#{viaturaAction.entity.prefixo}" 
						label="#{messages['label.prefixo']}" 
						required="true"
						maxlength="8"
						size="10" 
						onkeyup="toUpperCase(this,'')">
						<f:validateLength minimum="3" />
					</h:inputText>	
				
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml" >
					<ui:define name="label">#{messages['label.placa']}</ui:define>
					<h:inputText 
						style="text-transform:uppercase"
						id="placa"
						value="#{viaturaAction.entity.placa}" 
						label="#{messages['label.placa']}" 
						required="true"
						maxlength="8"
						size="10" >
						<rich:jQuery selector="#placa" query="mask('aaa-9999')" timing="onload" />
					</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.fabricacao']}</ui:define>
					<h:inputText 
						id="fabricacao"
						value="#{viaturaAction.entity.fabricacao}" 
						label="#{messages['label.fabricacao']}" 
						required="true"
						maxlength="4"
						size="10" >
						<rich:jQuery selector="#fabricacao" query="mask('9999')" timing="onload" />
					</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.modelo']}</ui:define>
					<h:inputText 
						id="modelo"
						value="#{viaturaAction.entity.modelo}" 
						label="#{messages['label.modelo']}" 
						required="true"
						maxlength="4"
						size="10" >
						<rich:jQuery selector="#modelo" query="mask('9999')" timing="onload" />
					</h:inputText>
				</s:decorate>
		    	<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.quantidadeOcupantes']}</ui:define>
					<h:inputText 
						id="quantidadeOcupantes"
						value="#{viaturaAction.entity.quantidadeOcupantes}" 
						label="#{messages['label.quantidadeOcupantes']}" 
						maxlength="3"
						size="10" 
						onkeypress="mascara(this,soNumeros)">
						
					</h:inputText>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml" rendered="not empty unidadesOperacionaisViatura">
					<ui:define name="label">#{messages['label.unidadesOperacionaisViatura']}</ui:define>
					<h:selectOneMenu 
						value="#{viaturaAction.entity.unidadesOperacionaisViatura}" 
						label="#{messages['label.unidadesOperacionaisViatura']}"
						style="width:300px;">
						<s:selectItems 
							var="_unidadesOperacionaisViatura" 
							value="#{viaturaAction.resultList}" 
							label="#{_unidadesOperacionaisViatura.viatura}"
							itemValue="#{_unidadesOperacionaisViatura}"
							noSelectionLabel="#{messages['label.selecione']}"/>
							<f:converter converterId="br.com.o2solutions.siso.webapp.converter.EntidadeBaseConverter"/>
					</h:selectOneMenu>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['label.ativa']}</ui:define>
					<h:selectBooleanCheckbox 
						value="#{viaturaAction.entity.ativa}" 
						label="#{messages['label.ativa']}" 
					/>
				</s:decorate>
				<s:decorate template="/layout/edit.xhtml" rendered="#{viaturaAction.entity.id != null}">
					<ui:define name="label">#{messages['label.adicionar.observacao']}</ui:define>
					<a4j:commandButton 
						image="/img/addIcon.png" 
						alt="#{messages['label.adicionar.observacao']}"
						title="#{messages['label.adicionar.observacao']}"/>
				</s:decorate>
			</rich:panel>
			<div>
				<a4j:commandButton 
					value="#{messages['label.salvar']}" 
					action="#{viaturaAction.save}"
					rendered="#{viaturaAction.entity.id == null}"/>
				<a4j:commandButton 
					value="#{messages['label.atualizar']}" 
					action="#{viaturaAction.update}"
					rendered="#{viaturaAction.entity.id != null}"/>
					
				<a4j:commandButton 
					value="#{messages['label.remover']}" 
					action="#{viaturaAction.remove}"
					rendered="#{viaturaAction.entity.id != null}"/>
					
				<s:button 
					propagation="none" 
					action="#" 
					value="#{messages['label.limpar']}">
				</s:button>
			</div>
		</h:form>
	</a4j:outputPanel>
</ui:fragment>
